<?php
	//Database class
	class Database{
		private static $mysqli;
		private function __construct() { } // block directly instantiating  
      
		private function __clone() { } // block cloning of the object  
		
		//Use this to connect to the Database
		public static function get() {
			if(!self::$mysqli) {
				/*
				//Include when there's ssh tunneling needed
				$connection = ssh2_connect('SERVER IP', 22); 
				ssh2_auth_password($connection, 'username', 'password');
				$tunnel = ssh2_tunnel($connection, 'DESTINATION IP', 2082);
				*/
				//Database details (config in includes.php)
				self::$mysqli = new mysqli(DATABASE_URI, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); 
				if(mysqli_connect_errno()) {
					throw new Exception('MySQL connection failed: ' . self::$instance->connect_error);
				}
				
			}
			
			return self::$mysqli;
		}
	}

?>